package com.dein.music.service.impl;

import com.dein.music.dao.MusicDislikeDao;
import com.dein.music.model.Music;
import com.dein.music.model.MusicDislike;
import com.dein.music.service.MusicDislikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service(value = "musicDislikeService")
public class MusicDislikeServiceImpl implements MusicDislikeService{
    protected MusicDislikeDao musicDislikeDao;

    @Autowired
    @Qualifier("musicDislikeDao")
    public void setMusicDislikeDao(MusicDislikeDao musicDislikeDao)
    {
        this.musicDislikeDao = musicDislikeDao;
    }

    @Override
    public boolean addDislikeMusic(Long userId, Long musicId) {
        try{
            musicDislikeDao.addDislikeMusic(userId,musicId);
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }

    @Override
    public boolean deleteDislikeMusic(Long userId, Long musicId) {
        try{
            musicDislikeDao.deleteDislikeMusic(userId,musicId);
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }

    @Override
    public Integer countDislikeMusic(Long userId) {
        try{
            return musicDislikeDao.countDislikeMusic(userId);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public List<Music> getDislikeMusicList(Long userId,Integer limit,Integer start) {
        try{
            return musicDislikeDao.getDislikeMusicList(userId,limit,start);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
}
